package com.servlet.service;

import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;

import com.servlet.dao.ConsumptionTypeDao;
import com.servlet.vo.ConsumptionType;

public class ConsumptionTypeService {

	private boolean flag = false;
	
	public boolean add(HttpServletRequest request) throws SQLException{
		
		ConsumptionType obj = new ConsumptionType();
		obj.setConsumptionTypeName(request.getParameter("consumptionTypeName"));
		
		flag = new ConsumptionTypeDao().save(obj);
		
		return flag;
	}
	
	public boolean del(HttpServletRequest request) throws SQLException{
		
		String objId = request.getParameter("objId");
		if(null != objId && !"".equals(objId)){

			flag = new ConsumptionTypeDao().delete(Long.parseLong(objId));
		}
		
		return flag;
	}
	
	public boolean update(HttpServletRequest req) throws SQLException{
		
		ConsumptionType obj = new ConsumptionType();
		obj.setId(Long.parseLong(req.getParameter("objId")));
		obj.setConsumptionTypeName(req.getParameter("consumptionTypeName"));
		
		flag = new ConsumptionTypeDao().update(obj);
		return flag;
	}
	
	
	
}
